import { useModel } from "umi";
import compress from "gql-compress";

const useMember = () => {
    const { graphqlFetch } = useModel("global");

    const loadMember = async (omUuid) => {
        let res = await graphqlFetch({
            query,
            variables: {
                omUuid,
            },
        });
        return res?.a || {};
    };

    return { loadMember };
};

const query = compress(`query MyQuery($omUuid: UUID!) {
    a: organizationMemberByOmUuid(omUuid: $omUuid) {
        omUuid
        omName
        omNati
        omPhon
        omRoge
        omIdnu
        omBirt
    }
}`);

export default useMember;
